* * * */public class Splitsentencebolt extends Baserichbolt {/
/baserichbolt is the implementation of IComponent and Ibolt interface//Inherit this class, it is not necessary to implement this example does not care about the method of private outputcollector collector;
The/** * Prepare () method is similar to the open () method of Ispout.
* This method is called during blot initialization and can be used to prepare the resources used by
component types (that is, all spout, bolts).Thrift the definition of spout or bolt is the same, so we just need to look at the thrift definition of the bolt. It contains 1 "componentobject" structures and a "componentcommon" structure."Componentobject" is the implementation entity of the bolt. It can be one of the following three types:
1 Serialized Java Objects (this object implements the Ibolt interface)
1 "shellcomponent" objects mean
the Baserichspout,So you don't have to implement the close, activate, deactivate, ACK, fail, and Getcomponentconfiguration methods, only the most basic parts of the core.Conclusion:Usually (except for shell and transactional type), implement a spout, can directly implement interface Irichspout, if you do not want to write redundant code, you can directly inherit baserichspout. "Bolt"The class diagram looks like this:Here's a curious question: Why didn't ibasicbolt inherit
Bolt is the basic unit of data processing in topology, and also a programming unit for the process of Storm . All the processing in the topology is done in these bolts. Bolts can send data items to multiple data streams (stream). Programmers can first declare multiple streams using the Declarestream () method of the Outputfieldsdeclarer class, specifying the stream to which the data will be sent. The data is then sent using the Spoutoutputcollector emit method (native spout).Storm provides progr
definition
A thrift definition for bolts contains componentobject structure and Componentcommon structure
Componentobject, which defines the implementation of the bolt, may be one of the following three types
A serialized Java object that implements the Ibolt
A shellcomponent represents the implementation of other languages, and when the bolt is declared in this way, it causes storm to instantiate a Shellbol
" is the implementation entity of the bolt. It can be one of the following three types:
1 Serialized Java Objects (this object implements the Ibolt interface)
1 "shellcomponent" objects means that bolts are implemented in other languages. If you define 1 bolt,storm in this way, 1 Shellbolt objects will be instantiated to handle the communication between the JVM-based worker process and the non-JVM component (that is, the bolt) implementat
stream from a component named "1". declarer.shufflegrouping ("1")IBolt and IComponent interfacesIbolt Interface://When the component's task is initially initialized, called by the worker process (worker) in the cluster, prepare () is used to instantiate the Bolt's given run-time task, which is called by one of the processes in the cluster to provide the environment in which the bolt runs.The Sormconf object maintains configuration information for the
bolts with the environment that the bolt executes. void Backtype.storm.task.IBolt.Execute(Tuple input)A single tuple that handles the input.Backtype.storm.topology.IrichboltInherit from Ibolt and IComponent.Backtype.storm.task. OutputcollectorThe output collector is used to emit a tuple from the Irichbolt.ListEmit (tuple anchor, listJet a new tuple to the default anchor on a single tuple stream.Backtype.storm.topology.InputDeclarer. shufflegrouping (
ensures that a processing unit runs forever (unless you explicitly kill the processing unit).Of course, if the middle state is stored in the processing unit, then when the processing unit is restarted by storm, it needs to apply itself to the recovery of the intermediate state.
Supports multiple programming languages
In addition to implementing spout and bolts in Java, you can do this with any programming language you are familiar with, thanks to Storm's so-called multi-lingual pr
and so on. Boltsbolts is a logical processing unit. The spouts passes the data to the bolts and bolts processes and produces a new output stream. Bolts can perform actions such as filtering, aggregating, joining, interacting with the data source and the database. The bolts receives data and emits it to one or more bolts. "IBolt" is the core interface to implement bolts. Some common interfaces are irichbolt,ibasicbolt and so on. Let's look at a
, materialize, control the partitioning of intermediate results, and so on. It can be said that the programming model is more flexible than Hadoop.
2. Multi-lingual support
In addition to implementing spout and bolts in Java, you can do this with any programming language you are familiar with, thanks to Storm's so-called multi-lingual protocol. A multi-language protocol is a special protocol within storm that allows spout or bolts to use standard input and standard output for message delivery, w
not the master)
Runstorm ui, Monitoring Storm running status through http: // localhost: 8080/
Use Storm. Net. Adapter to obtain Storm. Net. Adapter
Currently, you can obtain the latest Storm. Net. Adapter library in the following ways:
Compile your own version through source code: GitHub
Download the compiled version and add it to reference: Release
Use NuGet to obtain the latest version (recommended ):PM> Install-Package Storm.Net.Adapter
Create a sample project
Reference Storm. Net. A
Original address:Http://storm.apache.org/releases/1.0.1/Multilang-protocol.html This Protocol trial version after 0.7.1 Support for multiple languages through the Shellbolt and Shellspout and Shellprocess classes implements the Ibolt and Ispout interfaces,Also implements a protocol for executing scripts or programs through the shell using Java's Processbuilder class When using this protocol in Java, it is necessary to create an inherited Shellbolt bol
environment, the non-owner can only execute the sentence)
Run storm ui , monitor Storm health through http://localhost:8080/
Get Storm.Net.Adapter using Storm.Net.AdapterThere are currently several ways to get the latest Storm.Net.Adapter library
Compiling your own version with source code: GitHub
Download the compiled version Add Reference: Release
Get the latest version with NuGet (recommended):PM> Install-Package Storm.Net.Adapter
To create a sample project
tuple.Boltbacktype.storm.task. IBoltThis is the core interface of the Bolt class.There are several methods: void Backtype.storm.task.IBolt. Prepare (Map stormconf, Topologycontext context, outputcollector collector)When the task of this component is initialized within a worker in the cluster. The function is called. It provides the bolt with the environment in which the bolt runs.void Backtype.storm.task.IBolt. Execute (Tuple input)A single tuple that handles the input.Backtype.storm.topology.
In addition to implementing spout and bolts in Java, you can do this with any programming language you are familiar with, thanks to Storm's so-called multi-lingual protocol. A multi-language protocol is a special protocol within storm that allows spout or bolts to use standard input and standard output for message delivery, with a single line of text or multiple lines of JSON encoding.Storm supports multi-language programming primarily through Shellbolt, Shellspout, and shellprocess classe
draw, respectively, Ispout and Ibolt. Because we can understand that irichspout and Irichbolt are the combination of both and IComponent (inheritance). Then come the first, say spout:
void Open (Map conf, topologycontext context, spoutoutputcollector collector);
Call (not guaranteed to be called) void Close () when the spout terminates
;
Call
void Activate () when spout is activated;
Called when the spout is deactivated (possibly reactivated), th
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.